<template>
	<div class="basic-setting">
		<div class="title">其它设置</div>
		<el-form label-position="top" :model="settingForm">
			<el-form-item label="直播姬透明度">
				<el-slider
					v-model="settingForm.opacity"
					:format-tooltip="formatTooltip"
					@input="settingOpacity"
				></el-slider>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="openKeywords(true)"
					>设置自动回复关键字</el-button
				>
				<el-button type="primary" @click="openKeywords(false)"
					>设置触发音效关键字</el-button
				>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
export default {
	data() {
		return {
			settingForm: {
				// 直播姬透明度
				opacity: parseInt(localStorage.getItem("liveOpacity")) || 70,
			},
		};
	},
	methods: {
		// 格式化滑块
		formatTooltip(val) {
			return val / 100;
		},

		// 设置直播姬透明度
		settingOpacity(val) {
			localStorage.setItem("liveOpacity", val);
			this.$electron.ipcRenderer.send("setOpacity", val);
		},

		// 打开设置关键词窗口
		openKeywords(val) {
			localStorage.setItem("liveKeyword", val ? "1" : "0");
			this.$electron.ipcRenderer.send("open-keywords");
		},
	},
};
</script>

<style lang="scss"></style>
